package gob.osinerg.emergencia.service;

import gob.osinerg.emergencia.dao.GenericDAO;

import java.io.Serializable;
import java.sql.Connection;
import java.util.Collection;
import java.util.List;
import java.util.Map;

public class GenericServiceImpl implements GenericService{

	private GenericDAO dao;
	
	public void delete(Object persistentInstance) throws Exception {
		
		getDao().delete(persistentInstance);
	}

	public void deleteById(Class clazz, Serializable id) throws Exception {
		getDao().deleteById(clazz, id);
		
	}

	public Object findById(Class clazz, Serializable id) throws Exception {
		
		return getDao().findById(clazz, id);
	}

	public List findByObject(Object object) throws Exception {
		 
		return getDao().findByObject(object);
	}

	public List getFindCriteria(Object object) throws Exception {
		 
		return getDao().getFindCriteria(object);
	}

	public List getFindCriteria(Object object, String orderBy, String restringe)
			throws Exception {
		 
		return getDao().getFindCriteria(object, orderBy, restringe);
	}

	public List getFindCriteria(Object object, int maxResults) throws Exception {
		 
		return getDao().getFindCriteria(object, maxResults);
	}

	public void save(Object object) throws Exception {
		 getDao().save(object);
		
	}

	public void saveCollection(Collection collection) throws Exception {
		getDao().saveCollection(collection);
		
	}

	public List executeSQLQuery(String namedQuery, Map params) {
		return getDao().executeSQLQuery(namedQuery, params);
	}


	public Connection getConnection() throws Exception {
		return getDao().getConnection();
	}
	
	public GenericDAO getDao() {
		return dao;
	}

	public void setDao(GenericDAO dao) {
		this.dao = dao;
	}

	
}
